//package com.lepu.app.fun.knowledge.view;
//
//import java.util.ArrayList;
//import java.util.HashMap;
//import java.util.Map;
//
//import org.json.JSONObject;
//
//import com.app.application.MyApplication;
//import com.app.utils.Setting;
//import com.app.utils.UmengEvent;
//import com.core.lib.core.ApiClient;
//import com.core.lib.core.AsyncRequest;
//import com.core.lib.utils.main.UIHelper;
//import com.core.lib.utils.main.UmengHelper;
//import com.eyzhs.app.R;
//import com.lepu.app.fun.knowledge.KnowledgeReadDetailActivity;
//import com.lepu.app.fun.knowledge.adapter.KnowledgeAdapter;
//import com.lepu.app.fun.knowledge.bean.Article;
//import com.lepu.app.fun.knowledge.bean.ScrollImage;
//import com.lepu.app.fun.my.CollectKnowledgeActivity;
//import com.lepu.app.main.activity.AppBroswerActivity;
//import com.lepu.app.main.activity.MainTabActivity;
//import com.lepu.app.main.fragment.MainTabFragmentIndex;
//import com.lepu.app.widget.ImageHorizontalScrollView;
//import com.lepu.app.widget.ListViewForScrollview;
//
//import android.annotation.SuppressLint;
//import android.content.Context;
//import android.content.Intent;
//import android.os.Handler;
//import android.os.Message;
//import android.util.AttributeSet;
//import android.view.LayoutInflater;
//import android.view.View;
//import android.widget.Button;
//import android.widget.ImageButton;
//import android.widget.ImageView;
//import android.widget.LinearLayout;
//import android.widget.TextView;
//
//public class ReadView extends LinearLayout implements AsyncRequest {
//
//	private Context mContext;
//	private static final String REQUEST_DATA = "request_data";
//	private static final int MSG_DATA_SUCCESS = 10;
//	private static final int MSG_DATA_FAIL = 11;
//
//	public TextView mTop;
//	public ListViewForScrollview mReadListView;
//	public ImageButton mReadMoreButton;
//
//	public ArrayList<ImageView> mImageViewList = new ArrayList<ImageView>();
//	public ArrayList<Article> mArticleList;
//	public KnowledgeAdapter mAdapter;
//	public int[] mReadArray;
//	public final int pageSize = 3;
//	public int pageCount = 2;
//
//	public ReadView(Context context) {
//		super(context);
//
//		mContext = context;
//
//		LayoutInflater.from(mContext).inflate(R.layout.knowledge_read_view,
//				this, true);
//		init();
//	}
//
//	public ReadView(Context context, AttributeSet attrs) {
//		super(context, attrs);
//
//		mContext = context;
//
//		LayoutInflater.from(mContext).inflate(R.layout.knowledge_read_view,
//				this, true);
//		init();
//	}
//
//	private void init() {
//		mReadArray = getResources().getIntArray(R.array.array_read_id);
//
//		mTop = (TextView) findViewById(R.id.red_top);
//		ImageView readImageView1 = (ImageView) findViewById(R.id.one_read_imageview1);
//		ImageView readImageView2 = (ImageView) findViewById(R.id.one_read_imageview2);
//		ImageView readImageView3 = (ImageView) findViewById(R.id.one_read_imageview3);
//		ImageView readImageView4 = (ImageView) findViewById(R.id.one_read_imageview4);
//		ImageView readImageView5 = (ImageView) findViewById(R.id.one_read_imageview5);
//		ImageView readImageView6 = (ImageView) findViewById(R.id.one_read_imageview6);
//		ImageView readImageView7 = (ImageView) findViewById(R.id.one_read_imageview7);
//		ImageView readImageView8 = (ImageView) findViewById(R.id.one_read_imageview8);
//		LinearLayout mScrollLayout = (LinearLayout) findViewById(R.id.read_scroll_image_layout);
//		mReadMoreButton = (ImageButton) findViewById(R.id.read_more_data);
//
//		mImageViewList.add(readImageView1);
//		mImageViewList.add(readImageView2);
//		mImageViewList.add(readImageView3);
//		mImageViewList.add(readImageView4);
//		mImageViewList.add(readImageView5);
//		mImageViewList.add(readImageView6);
//		mImageViewList.add(readImageView7);
//		mImageViewList.add(readImageView8);
//
//		for (int i = 0; i < mImageViewList.size(); i++) {
//			mImageViewList.get(i).setOnClickListener(
//					new MyButtonOnclicklistener(mReadArray[i]));
//		}
//
//		mTop.setOnClickListener(new MyButtonOnclicklistener());
//		mReadMoreButton.setOnClickListener(new MyButtonOnclicklistener());
//
//		// 横向滚动ImageView
//		ArrayList<ScrollImage> scrollImageList = new ArrayList<ScrollImage>();
//		ScrollImage scrollImage1 = new ScrollImage();
//		scrollImage1.imageId = R.drawable.one_scroll_image1;
//		scrollImage1.title = "月子餐大参考";
//		scrollImage1.contentUrl = "http://dl.eyzhs.com/kexueyunyu/yuezican/list.html";
//
//		ScrollImage scrollImage2 = new ScrollImage();
//		scrollImage2.imageId = R.drawable.one_scroll_image2;
//		scrollImage2.title = "辣妈瘦身记";
//		scrollImage2.contentUrl = "http://dl.eyzhs.com/kexueyunyu/chanhouyundong/list.html";
//
//		ScrollImage scrollImage3 = new ScrollImage();
//		scrollImage3.imageId = R.drawable.one_scroll_image3;
//		scrollImage3.title = "0-6周宝宝成长发育指南";
//		scrollImage3.contentUrl = "http://dl.eyzhs.com/kexueyunyu/6weekbaby/list.html";
//
//		scrollImageList.add(scrollImage1);
//		scrollImageList.add(scrollImage2);
//		scrollImageList.add(scrollImage3);
//
//		ImageHorizontalScrollView scrollImageView = new ImageHorizontalScrollView(
//				mContext, scrollImageList);
//		mScrollLayout.addView(scrollImageView);
//
//		LinearLayout layout1 = (LinearLayout) findViewById(R.id.read_layout1);
//		LinearLayout layout2 = (LinearLayout) findViewById(R.id.read_layout2);
//		mReadListView = (ListViewForScrollview) findViewById(R.id.read_listview);
//
//		layout1.setOnClickListener(new MyButtonOnclicklistener());
//		layout2.setOnClickListener(new MyButtonOnclicklistener());
//
//	}
//
//	public void loaddata(ArrayList<Article> dataList) {
//		if (dataList != null && dataList.size() > 0) {
//			mArticleList = dataList;
//			mAdapter = new KnowledgeAdapter(mContext, mArticleList);
//			mReadListView.setAdapter(mAdapter);
//		}
//	}
//
//	class MyButtonOnclicklistener implements View.OnClickListener {
//		public int readId;
//
//		public MyButtonOnclicklistener() {
//
//		}
//
//		public MyButtonOnclicklistener(int readId) {
//			this.readId = readId;
//		}
//
//		@Override
//		public void onClick(View v) {
//			int rid = v.getId();
//			switch (rid) {
//			case R.id.one_read_imageview1:
//			case R.id.one_read_imageview2:
//			case R.id.one_read_imageview3:
//			case R.id.one_read_imageview4:
//			case R.id.one_read_imageview5:
//			case R.id.one_read_imageview6:
//			case R.id.one_read_imageview7:
//				Intent intentRead = new Intent(mContext,
//						KnowledgeReadDetailActivity.class);
//				intentRead.putExtra("readId", readId);
//				MainTabActivity.getInstance().startActivity(intentRead, true);
//				break;
//			case R.id.one_read_imageview8:
//				Intent intentMore = new Intent(mContext,
//						CollectKnowledgeActivity.class);
//				intentMore.putExtra("flag", true);
//				MainTabActivity.getInstance().startActivity(intentMore, true);
//				break;
//			case R.id.red_top:
//				
//				UmengHelper.CustomEvent(mContext,
//						UmengEvent.event_kexueyunyu_yuezi_top);
//				
//				MainTabFragmentIndex.getInstance().mHandler
//						.sendEmptyMessage(MainTabFragmentIndex.MSG_READ_TOP);
//				break;
//			case R.id.read_layout1:
//				Intent intentRead1 = new Intent(mContext,
//						AppBroswerActivity.class);
//				intentRead1.putExtra("no_need_menu", false);
//				intentRead1.putExtra("url",
//						"http://dl.eyzhs.com/kexueyunyu/yueziday/nav.html");
//				intentRead1.putExtra("title", "月子护理大全");
//				MainTabActivity.getInstance().startActivity(intentRead1, true);
//				
//				//test
////				int flag = AppConfig.getConfigInt(mContext, Const.CONFIG_APP_BIRTH_WAY_SELECT, 0);
////				if(flag == 0)
////				{
////					Intent intent1 = new Intent(mContext,KnowledgeBirthWayActivity.class);
////					MainTabActivity.getInstance().startActivity(intent1, true);
////				}else{
////					String url = "";
////					if(flag == 10)
////					{
////						url = "";
////					}else{
////						url = "";
////					}
////					Intent intent2 = new Intent(mContext,AppImageBroswerActivity.class);
////					intent2.putExtra("url", url);
////					MainTabActivity.getInstance().startActivity(intent2, true);
////				}
//				break;
//			case R.id.read_layout2:
//				Intent intentRead2 = new Intent(mContext,
//						AppBroswerActivity.class);
//				intentRead2.putExtra("no_need_menu", false);
//				intentRead2
//						.putExtra("url",
//								"http://dl.eyzhs.com/kexueyunyu/zaochanerhuli/list.html");
//				intentRead2.putExtra("title", "早产儿护理");
//				MainTabActivity.getInstance().startActivity(intentRead2, true);
//				break;
//			case R.id.read_more_data:
//				
//				UmengHelper.CustomEvent(mContext,
//						UmengEvent.event_kexueyunyu_yuezi_more);
//				request();
//				break;
//			default:
//				break;
//			}
//		}
//	}
//
//	public void request() {
//		Map<String, Object> map = new HashMap<String, Object>();
//		JSONObject params = new JSONObject();
//		try {
//			params.put("DeviceID", Setting.DEVICEID);
//			params.put("ApplicationID", Setting.APPLICATIONID);
//			params.put("UserID",
//					MyApplication.getInstance().getLoginInfo().UserID);
//			params.put("LoginToken",
//					MyApplication.getInstance().getLoginInfo().LoginToken);
//			params.put("ACIDList", "12");
//			params.put("PageIndex", pageCount);
//			params.put("PageSize", pageSize);
//			params.put("RefreshTime",
//					MainTabFragmentIndex.getInstance().mRefreshTime);
//			params.put("SortDirection", "DESC");
//
//		} catch (Exception e) {
//		}
//		map.put("ht", params);
//
//		ApiClient.http_post(Setting.getArticleListUrl(), map, null, this,
//				REQUEST_DATA, false,false,true);
//		MainTabActivity.getInstance().showProgressDialog();
//	}
//
//	@SuppressLint("HandlerLeak")
//	@SuppressWarnings("unchecked")
//	public Handler mHandler = new Handler() {
//		public void handleMessage(Message msg) {
//			switch (msg.what) {
//			case MSG_DATA_SUCCESS:
//				MainTabActivity.getInstance().hideProgressDialog();
//				ArrayList<Article> articleList = (ArrayList<Article>) msg.obj;
//				if (articleList != null && articleList.size() > 0) {
//					mArticleList.addAll(articleList);
//					mAdapter.notifyDataSetChanged();
//					pageCount++;
//
//					if (articleList.size() < pageSize) {
//						mReadMoreButton.setVisibility(View.GONE);
//					}
//				}else{
//					UIHelper.showToast(MyApplication.getInstance(), R.string.no_data_more);
//					mReadMoreButton.setVisibility(View.GONE);
//				}
//				break;
//			case MSG_DATA_FAIL:
//
//				break;
//
//			default:
//				break;
//			}
//		};
//	};
//
//	@Override
//	public void RequestComplete(Object object, Object data) {
//		// 解析json data
//		ArrayList<Article> dataArray = Article.parseJsonData((String) data);
//
//		Message msg = mHandler.obtainMessage();
//		msg.what = MSG_DATA_SUCCESS;
//		msg.obj = dataArray;
//		mHandler.sendMessage(msg);
//	}
//
//	@Override
//	public void RequestError(Object object, int errorId, String errorMessage) {
//
//	}
//}
